<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="m" uri="/cutm_tags"%>
<html>
<head>
<title>节目设置</title>
<script type="text/javascript">
$(document).ready(function(){
	$('#programform').vaildAjax(function(data){
		if(data.charAt(0) =='a'){
			$('input[name="enums.id"]').val(data.substring(1));
			var tr = '<tr id="exp'+data.substring(1)+'"><td><input type="radio" checked="checked" name="opera" value="'+data.substring(1)+'" /></td>';
			tr+='<td>'+$('input[name="enums.key"]').val()+'</td>';
			tr+='<td>'+($('input[name="enums.disable"]').radio()=='false'?'可用':'已禁用')+'</td>';
			tr+='<td>'+$('input[name="enums.comment"]').val()+'</td>';
			$('table.list').append(tr);
			BaseJs.alert('添加节目成功');
		}
		if(data.charAt(0) =='u'){
			var tds = $('#exp'+data.substring(1)+" td");
			$(tds[1]).text($('input[name="enums.key"]').val());
			$(tds[3]).text($('input[name="enums.disable"]').radio()=='false'?'可用':'已禁用');
			$(tds[4]).text($('input[name="enums.comment"]').val());
			BaseJs.alert('修改节目信息成功');
		}
	});
	<s:if test="enums==null" >
		$('input[name="enums.disable"]').radio('false');
	</s:if>
	$('.opera').click(function(){
		var tds = $('#exp'+$(this).val()+' td');
		$('input[name="enums.id"]').val($(this).val());
		$('input[name="enums.key"]').val($(tds[1]).text());
		$('input[name="enums.disable"]').radio($(tds[2]).text()=='已禁用');
		$('input[name="enums.comment"]').val($(tds[3]).text());
	});
});
</script>
</head>
<body>
<h2 class="title"><span>栏目设置</span><m:imgA img="add" msg="添加新用户" onclick="javascript:BaseJs.reload();" /></h2>
<s:form id="programform" action="program/ListPrograme!save">
	<s:hidden name="enums.id" />
	<s:hidden name="enums.type" value="program.type" />
	<table class="form">
		<tr>
			<th width="10%">节目名称</th>
			<td width="20%"><s:textfield name="enums.key" maxlength="50" cssClass="rule[required]" /></td>
			<th width="10%">是否可用</th>
			<td width="20%"><s:radio list="#{false:'可用',true:'已禁用'}" name="enums.disable" cssClass="rule[required]" /></td>
			<th width="10%">备注信息</th>
			<td width="30%"><s:textfield name="enums.comment" maxlength="250" /></td>
		</tr>
	</table>
	<div class="btnGroup"><s:submit value="保存" /></div>
</s:form>

<table class="list">
	<tr>
		<th width="10%">操作</th>
		<th width="20%">栏目名称</th>
		<th width="10%">是否可用</th>
		<th width="60%">备注</th>
	</tr>
	<s:iterator value="epages.items">
		<tr id="exp${id}">
			<td><input type="radio" class="opera" name="opera" value="${id}" /></td>
			<td><s:property value="key" /></td>
			<td><s:if test="disable">已禁用</s:if><s:else>可用</s:else></td>
			<td><s:property value="comment"/></td>
		</tr>
	</s:iterator>
</table>
<m:page value="${epages}" showSeaBar="true" />
</body>
</html>